<?php
function curl_gethtml($url) {

	  if (empty($url)) {
		   return false;
          }

	  $ch = curl_init();//初始化curl
          curl_setopt($ch, CURLOPT_URL,$url);//抓取指定网页
	                
	  curl_setopt($ch, CURLOPT_FOLLOWLOCATION,true);//url跳转自动抓取
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//如果成功只将结果返回，不自动输出任何内容
	                
	  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
		   
	  curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); // 模拟用户使用的浏览器
       
       	  $data = curl_exec($ch);//运行curl
          curl_close($ch);
	  return $data;
}
//$data =  curl_gethtml("http://freev2.org");
$url = "http://isx.yt/";
$savefile = "./ishadowv2ray.txt";
$data  = curl_gethtml($url);
//echo $data;
/********** for file is not available ********/
// 正则匹配
$v2ray_info = "";
$pattern = "/data-clipboard-text=\"([\s\S]*?)\"/";
$num = preg_match_all($pattern, $data, $arr,PREG_PATTERN_ORDER);
foreach($arr[1] as $value){
  //echo "{$value}<br>";
  $v2ray_info .= $value;
}
echo base64_encode($v2ray_info);
//var_dump($num);
//var_dump($matches);
//file_put_contents($savefile,$data);
/********** for file is writable
//echo $data;
file_put_contents($savefile,print_r($data,true));
//$str = str_replace("text","",$data);
//echo $str;
$v2ray_info = "";
if(file_exists($savefile)){

	$handler = fopen($savefile,"r");
	while( !feof($handler) )
	{
		$line = fgets($handler, 4096);//逐行读取，4096最大长度，默认1024;
		#echo $line;
		if( substr_count($line,"vmess:") > 0 )
		{
			//echo $line;
			$arr = explode('"',$line);
			//echo base64_encode($arr[3]);
			//echo $arr[5];
			$v2ray_info .= $arr[5];
		}
	}
	echo base64_encode($v2ray_info);
}
********/
?>